package com.example.mutichatkotlin

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import kotlinx.android.synthetic.main.login_layout.*

class LoginActivity : BaseActivity(), View.OnClickListener{
    private var accountEdit:EditText?=null
    private var passwordEdit:EditText?=null
    private var login:Button?=null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.login_layout)
        accountEdit=findViewById(R.id.username);
        passwordEdit=findViewById(R.id.password)
        login=findViewById<Button>(R.id.login)
        login?.setOnClickListener(this);
    }
    override fun onClick(v: View?) {
        if(v?.id==R.id.login){
                Log.e("click","hello")
                val username=accountEdit?.text.toString()
                if(username.trim() == "" ||username==null){
                    Toast.makeText(this,"用户名不能为空，请重新输入",Toast.LENGTH_SHORT).show()
                }else{
                    MainActivity.actionStart(this@LoginActivity,username)
                    finish()
                }
        }
    }
}
